<?php
require 'Pager.php';
include_once'../classeBDD/connectBdd.php';
$sql = sql::connect();

   $requery = $sql->query('SELECT * FROM region');
   $num_products=$sql->num_rows($requery);

$pager_options = array(
'mode'       => 'Sliding',
'perPage'    => 5,
'delta'      => 1,
'totalItems' => $num_products,
);
$pager = Pager::factory($pager_options);
//then we fetch the relevant records for the current page
list($from, $to) = $pager->getOffsetByPageId();
//$resul=$pager->getOffsetByPageId();
//print_r($resul);

//set the OFFSET and LIMIT clauses for the following query
//$db->setLimit($pager_options['perPage'], $from-1);
$r=$from-1;

 $req=$sql->query('SELECT * FROM region ORDER  BY id_region LIMIT '.$r.', '.$pager_options['perPage'].'');
 //print_r($req);
//echo $pager_options['perPage'].'<br/>'.$from.'<br/>';
//$products=& $db->getAll('SELECT * FROM region ',$pager_options['perPage'], $from);

//var_dump($products);die;
//$query = 'SELECT * FROM region';
//$products = $db->queryAll($query, null, MDB2_FETCHMODE_ASSOC);
//show the results
echo '<ul>';
while( $product = $sql->fetch_array($req)){
/*foreach ($products as $product) */
echo '<li>'.$product['id_region'].': '.$product['nom_region'].'</li>';
}
echo '</ul>';
//show the links
echo $pager->links;

?>